package com.pangus.toolkits.files.download;

import com.pangus.toolkits.files.model.FileInfo;
import com.pangus.toolkits.files.operation.FSFileOperation;

/**
 * @author yingheng chen
 * @description
 * @date 2019/12/5
 */
public class DownloadStrategyFactory {
    private final static Long LIMIT = 15 * 1024 * 1024L;

    /**
     * 如果文件大于30M,则启动分片策略，
     * 否则直接下载
     *
     * @param fileInfo
     * @param fileOperation
     * @return
     */
    public static DownloadStrategy create(FileInfo fileInfo, FSFileOperation fileOperation) {
        if (fileInfo.getSize() < LIMIT) {
            return new SimpleDownload(fileInfo, fileOperation);
        } else {
            return new ResumePartDownload(fileInfo, fileOperation);
        }
    }
}
